import maya.cmds as cmds
cmds.SelectAll();
cmds.Delete();

wallThickness = 1.0;
cameraheight = 35.0;
cameraWidth = 43.0;
holderWidth = 45.0;
nexusHeight = 180.0;
nexusThickness = 10.5;
nexusHeightFudge = 0.1;
lipWidth = 5.0;
holeDiameter = 5.0;
leftHoleHeight = cameraheight/ 2.0 - 4.0;
leftHoleOffset = (cameraWidth / 2.0) - 0.8 - (holeDiameter /2.0) + 0.1;

rightHoleHeight = cameraheight/ 2.0 - 1.0;
rightHoleOffset = (cameraWidth / 2.0) - 2.8 - (holeDiameter /2.0) - 0.1;

lensHoleDiameter = 18.0;
lensHoleHeight = 16.2;



outer = cmds.polyCube(w=(cameraWidth+wallThickness*2), h=(nexusThickness + wallThickness*2),d=(nexusHeight+ cameraheight +wallThickness*3));
inner = cmds.polyCube(w=(cameraWidth+wallThickness*2), h=(nexusThickness + nexusHeightFudge),d=(nexusHeight));
innerCutter = cmds.polyCube(w=(cameraWidth+wallThickness*2), h=(nexusThickness*2),d=(nexusHeight - lipWidth*2));
cameraCutter = cmds.polyCube(w=(cameraWidth+wallThickness*2), h=(nexusThickness*2),d=(cameraheight + wallThickness));

leftHole = cmds.polyCylinder(sa=100,r=holeDiameter/2.0,h=nexusThickness*2)#by this point height is only wallthickness deep, so this should be plenty
rightHole = cmds.polyCylinder(sa=100,r=holeDiameter/2.0,h=nexusThickness*2)
lensHole = cmds.polyCylinder(sa=100,r=lensHoleDiameter/2.0,h=nexusThickness*2)


cmds.select(cameraCutter[0],outer[0]);
cmds.align(z='max',alignToLead=True);

cmds.select(lensHole[0],cameraCutter[0]);
cmds.align(z='mid',alignToLead=True);

cmds.select(lensHole[0]);
cmds.move(0,0,3,relative=True);#moving up to allow room for screws

cmds.select(leftHole[0],lensHole[0]);
cmds.align(z='mid',alignToLead=True);

cmds.select(leftHole[0]);
cmds.move(leftHoleOffset,0,-leftHoleHeight,relative=True);

cmds.select(rightHole[0],lensHole[0]);
cmds.align(z='mid',alignToLead=True);

cmds.select(rightHole[0]);
cmds.move(-rightHoleOffset,0,-rightHoleHeight,relative=True);

 
cmds.select(inner[0],outer[0]);
cmds.align(z='min',alignToLead=True);
 
cmds.select(innerCutter[0],outer[0]);
cmds.align(z='min',alignToLead=True);
 

 
cmds.select(innerCutter[0],inner[0]);
cmds.align(y='min',alignToLead=True);
 
 
cmds.select(innerCutter[0]);
cmds.move(0,0,wallThickness+lipWidth,relative=True);

innerCutter2 = cmds.duplicate(innerCutter[0]);
cmds.select(innerCutter2);
cmds.scale((cameraWidth-2*wallThickness)/(cameraWidth+wallThickness*2),1,1,relative=True);
cmds.move(0,-wallThickness,0,relative=True);




 
cmds.select(inner[0]);
cmds.move(0,0,wallThickness,relative=True);
 
cmds.select(cameraCutter[0],outer[0]);
cmds.align(y='min',alignToLead=True);
cmds.select(cameraCutter[0]);
cmds.move(0,wallThickness,0,relative=True);

 
 
cmds.select(outer[0],inner[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);
  
cmds.select(outer[0],innerCutter[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);

cmds.select(outer[0],innerCutter2[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);
  
cmds.select(outer[0],cameraCutter[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);
   
cmds.select(outer[0],leftHole[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);
  
cmds.select(outer[0],rightHole[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);
  
cmds.select(outer[0],lensHole[0]);#can't figure out why this is the proper order
outer = cmds.polyBoolOp(op=2);
cmds.rotate('90deg',0,0);
